home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #306 (1994)(Rhein-Sieg-Soft).zip / Franz PD Disk #306 (1994)(Rhein-Sieg-Soft).adf / mand2000 / arexx / JuliaMovie.mnd2 < prev    next >
Text File  |  1993-11-09  |  8KB  |  242 lines

  1. /* This script is supplied with the Mand2000 demo and release */
  2. /* versions and may be freely distributed. */
  3. /* Copyright 1993 Cygnus Software. */
  4.  
  5.  
  6. /* Set the total number of frames to be calculated. */
  7.  
  8. NumFrames = 20
  9.  
  10.  
  11.  
  12. /*
  13.     This script is for calculating Julia seed movies.  As you drag
  14. the  Julia  seed  across  the  Mandelbrot  set  the  Julia set changes
  15. dramatically,  and  this  script  allows  you  to  easily calculate an
  16. animation  of  these  changes,  thus allowing you to play them back in
  17. real time.
  18.  
  19.     This  script  takes the julia seed location when you initially
  20. run the script as the start point, and then asks you to select another
  21. point.   It  then smoothly moves from one pointer to the other, saving
  22. the frames out as calculated.  If you ask it to save out full screens,
  23. then the Mandelbrot set with the seed pointer moving across it will be
  24. saved also, showing the cause and effect.
  25.  
  26.     The  number  of  frames  calculated  can  easily be changed by
  27. adjusting the variable at the top of the script.
  28.  
  29.     The  resulting  sequence  of  frames can be easily loaded into
  30. DPaint or any other program for creating animations.
  31.  
  32.     This script will, optionally, use ADPro to create an animation
  33. file  out  of the individual frames as they are generated.  This saves
  34. time  and  reduces  the  user intervention required to create a movie.
  35. Also,  if the script were modified so that the frames were deleted off
  36. of the disk as soon as they had been put into the Anim, the disk space
  37. required would be reduced.
  38.     */
  39.  
  40. portname = address()    /* Retrieve the current port name. */
  41. /* If the portname does not start with MAND2000 then this script must */
  42. /* have been run with rx, rather than from Mand2000.  Therefore we */
  43. /* need to set the port name.  We do not always set the port name */
  44. /* because it is better to let Mand2000 set it for us, so that */
  45. /* this script can be used with windows other than the one with */
  46. /* port name MAND2000.1. */
  47. if (left(portname, 8) ~= "MAND2000") THEN
  48.     address 'MAND2000.1'
  49.  
  50. options results
  51.  
  52. /*Parse out the command option.  This script is called when the*/
  53. /*user wants a movie started, when the user wants a movie*/
  54. /*aborted and whenever one of the pictures in the sequence is done.*/
  55.  
  56. parse arg command
  57.  
  58. command = upper(command)    /* Make sure the command is in upper case. */
  59.  
  60. if (command = START) then
  61.     CALL StartJULIAMovie()
  62. else if (command = STOP) then
  63.     CALL StopJULIAMovie()
  64. else
  65.     CALL ContinueJULIAMovie()
  66.  
  67. Exit
  68.  
  69.  
  70.  
  71. StartJULIAMovie:
  72.     GETATTR stem PROJ
  73.     /* Julia fractal types are always odd. */
  74.     if ((PROJ.FRACTALTYPE // 2) ~= 1) THEN DO
  75.         DISPLAYMESSAGE PROMPT "A Julia window must be active when|making these movies.  Please|activate a Julia window and try|again."
  76.         EXIT
  77.         END
  78.  
  79.     GETATTR stem PROJ
  80.     StartX = PROJ.JuliaX
  81.     StartY = PROJ.JuliaY
  82.     CALL SETCLIP("JuliaMovieStart.X", PROJ.JuliaX)
  83.     CALL SETCLIP("JuliaMovieStart.Y", PROJ.JuliaY)
  84.  
  85.     DECPAUSE        /* Allow Mand2000 to resume calculating while this script executes. */
  86.  
  87.     REQUESTER JULIASEED    /* See whether the julia seed requester is up already. */
  88.     juliaseedstate = RESULT
  89.     REQUESTER JULIASEED ON    /* Force it to be up regardless. */
  90.  
  91.     REQUESTNOTIFY "The current seed location will be|used as the animation start.|Select the end seed location and|click `Continue'."
  92.  
  93.     GETATTR stem PROJ
  94.     CALL SETCLIP("JuliaMovieEnd.X", PROJ.JuliaX)
  95.     CALL SETCLIP("JuliaMovieEnd.Y", PROJ.JuliaY)
  96.  
  97.     /* Turn the julia seed requester off, if that's how it started. */
  98.     if (juliaseedstate = 0) THEN
  99.         REQUESTER JULIASEED OFF
  100.  
  101.     /* Put a command in the user menu for stopping the movie creation. */
  102.     menu '"------------------------"'
  103.     menu '"Stop Julia Movie"' JuliaMovie stop
  104.  
  105.     INCPAUSE        /* Stop calculations again. */
  106.     CALL SETCLIP("Mand2000FrameNum", 10001)
  107.     /* Tell Mand2000 to call this script whenever a pictures finishes calculating. */
  108.     EVENTACTION PICTUREDONE JuliaMovie
  109.  
  110.     /* Assume that ADPro is not wanted. */
  111.     CALL SETCLIP("JULIATOADPRONAME")
  112.     /* Then ask if it is. */
  113.     REQUESTRESPONSE "Would you like the frames|written to an anim file|by ADPro?"
  114.     if (RC = 0) THEN DO
  115.         REQUESTSAVEFILE 'title="Julia anim file name."' 'path="RAM:"' 'file="JuliaAnim"'
  116.         CALL SETCLIP("JULIATOADPRONAME", result)
  117.         END
  118.  
  119.     /* Assume that window only is wanted. */
  120.     CALL SETCLIP("JULIAWINDOWONLY", 1)
  121.     /* Then ask if it is. */
  122.     REQUESTRESPONSE "Would you like full screen|images saved?"
  123.     if (RC = 0) THEN DO
  124.         CALL SETCLIP("JULIAWINDOWONLY", 0)
  125.         END
  126.  
  127.     SETJULIA StartX StartY
  128.     RETURN 0
  129.  
  130.  
  131.  
  132. StopJULIAMovie:
  133.     /* Tell Mand2000 not to call this script any more. */
  134.     EVENTACTION PICTUREDONE
  135.     /* Remove the `stop Julia movie' menu. */
  136.     CLEARNMENUS 2
  137.     FRAMENUM = GETCLIP("Mand2000FrameNum")
  138.     if (FRAMENUM = "") THEN
  139.         EXIT
  140.     CALL SETCLIP("Mand2000FrameNum")
  141.     AnimName = GETCLIP("JULIATOADPRONAME")
  142.     if (AnimName ~= "") THEN DO
  143.         if ~show('p',"ADPro") THEN
  144.             EXIT
  145.         /* Start sending commands to ADPro. */
  146.         ADDRESS "ADPro"
  147.         /* Specify that we want to save an animation file. */
  148.         SFORMAT Anim
  149.         /* Save as anim frame. */
  150.         SAVE AnimName IMAGE WRAPUP BYTE FASTER
  151.         Why = ADPRO_RESULT
  152.         if (RC ~= 0) THEN DO
  153.             REQUESTNOTIFY "Error in wrap up.|Aborting animation."
  154.             CALL StopJULIAMovie()
  155.             EXIT
  156.             END
  157.         /* Resume sending commands to Mand2000. */
  158.         ADDRESS
  159.         if (FRAMENUM = 10001) THEN
  160.             REQUESTNOTIFY "Zero frames created."
  161.         else if (FRAMENUM = 10002) THEN
  162.             REQUESTNOTIFY "One frame created."
  163.         else
  164.             REQUESTNOTIFY "Just created a "FRAMENUM - 10001" frame anim.|Use DPaint or View to play it."
  165.         EXIT
  166.         END
  167.     if (FRAMENUM = 10001) THEN
  168.         REQUESTNOTIFY "Zero frames created."
  169.     else if (FRAMENUM = 10002) THEN
  170.         REQUESTNOTIFY "One frame created."
  171.     else
  172.         REQUESTNOTIFY "Just created "FRAMENUM - 10001" Julia frames.|Use ADPro or DPaint to make these|into an animation."
  173.     RETURN 0
  174.  
  175.  
  176.  
  177. ContinueJULIAMovie:
  178.     FRAMENUM = GETCLIP("Mand2000FrameNum")
  179.     WINDOWONLY = GETCLIP("JULIAWINDOWONLY")
  180.     if (WINDOWONLY = 1) THEN
  181.         SAVEAS "NAME=RAM:JULIAFRAME"FRAMENUM 1    /* Save the location and graphics (type 1) of the frame. */
  182.     ELSE
  183.         SAVESCREENAS "NAME=RAM:JULIAFRAME"FRAMENUM
  184.     if (RC ~= 0) THEN DO
  185.         REQUESTNOTIFY "Error in saving frame "FRAMENUM".|Aborting animation."
  186.         CALL StopJULIAMovie()
  187.         EXIT
  188.         END
  189.     AnimName = GETCLIP("JULIATOADPRONAME")
  190.     if (AnimName ~= "") THEN DO
  191.         if ~show('p',"ADPro") THEN DO
  192.             REQUESTNOTIFY "Error - ADPro is not running.|Aborting animation."
  193.             CALL StopJULIAMovie()
  194.             EXIT
  195.             END
  196.         /* Start sending commands to ADPro. */
  197.         ADDRESS "ADPro"
  198.         /* Specify that we want to load an IFF file. */
  199.         LFORMAT IFF
  200.         /* Load the last generated frame, don't bother converting to 24 bit. */
  201.         Load "RAM:JULIAFRAME"FRAMENUM nopad
  202.         if (RC = 10) THEN DO
  203.             REQUESTNOTIFY "Error in loading to ADPro.|Aborting animation."
  204.             CALL StopJULIAMovie()
  205.             EXIT
  206.             END
  207.         /* Specify that we want to save an animation file. */
  208.         SFORMAT Anim
  209.         /* Save as anim frame. */
  210.         SAVE AnimName IMAGE APPEND BYTE FASTER
  211.         Why = ADPRO_RESULT
  212.         if (RC ~= 0) THEN DO
  213.             REQUESTNOTIFY "Error in anim save.|Aborting animation."
  214.             CALL StopJULIAMovie()
  215.             EXIT
  216.             END
  217.         /* Resume sending commands to Mand2000. */
  218.         ADDRESS
  219.         /* At this point the IFF file could be deleted from the RAM disk. */
  220.         END
  221.     FRAMENUM = FRAMENUM + 1
  222.     CALL SETCLIP("Mand2000FrameNum", FRAMENUM)
  223.  
  224.     FRAMENUM = FRAMENUM - 10001    /* Subtract off the starting frame number. */
  225.     IF (FRAMENUM > (NumFrames - 1)) THEN DO
  226.         CALL StopJuliaMovie()
  227.         EXIT
  228.         END
  229.     DONERATIO = FRAMENUM / (NumFrames - 1)    /* Calculate doneratio to be between 0.0 and 1.0. */
  230.     StartX = GETCLIP("JuliaMovieStart.X")
  231.     StartY = GETCLIP("JuliaMovieStart.Y")
  232.     EndX = GETCLIP("JuliaMovieEnd.X")
  233.     EndY = GETCLIP("JuliaMovieEnd.Y")
  234.  
  235.     /* Calculate a new julia seed, part way between start and end. */
  236.     NewX = StartX + (EndX - StartX) * DONERATIO
  237.     NewY = StartY + (EndY - StartY) * DONERATIO
  238.  
  239.     /* Set a new julia seed. */
  240.     SETJULIA NewX NewY
  241.     RETURN 0
  242.